<?php
/**
 * 截取中文字符串
 * mb_substr()
 */
header('content-type:text/html;charset=utf-8');
mb_internal_encoding("UTF-8");

echo "过滤空格str_replace<br/>";
$str = '曾　   经的里面都化为无';
$str = str_replace(array(" ",  "　", "\t", "\n", "\r", "\0", "\x0B"), '', $str);
var_dump($str);
echo "<br/>截取字符串mb_substr<br/>";
$name = mb_substr($str, 0, 6, 'utf-8');
var_dump($name);


var_dump(iconv_get_encoding('all'));
echo "<br/>保留gbk和utf-8字符iconv<br/>";
$uid['screen_name'] = 'ℳ๓  ㎕   穷  蛋';
$uname = str_replace(array(" ", "　", "\t", "\n", "\r", "\0", "\x0B"), '', $uid['screen_name']);
$uname = iconv('utf-8', 'gbk//IGNORE', $uname);
var_dump('utf-8 convert gbk',$uname);
$uname = iconv('gbk', 'utf-8//IGNORE', $uname);
var_dump('gbk convert utf-8 ',$uname);
